package com.wenhuitec.sysui.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wenhuitec.sysui.R;

import com.wenhuitec.sysui.adapter.RadioGroupAdapter;

import java.util.List;
import java.util.Map;

/**
 * @Description 单选选择提示框
 */
public class RadioGroupDialog {
    private View view;

    public void RadioGroupDialog(Context context, List<Map<String, String>> list) {
        //1、使用Dialog、设置style
        final Dialog dialog = new Dialog(context, R.style.DialogTheme);
        //2、设置布局
        view = View.inflate(context, R.layout.dialog_radio_group, null);
        dialog.setContentView(view);

        Window window = dialog.getWindow();
        //设置弹出位置
        window.setGravity(Gravity.BOTTOM);
        //设置弹出动画
        window.setWindowAnimations(R.style.main_menu_animStyle);
        //设置对话框大小
        window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        dialog.show();

        //点击关闭按钮
        dialog.findViewById(R.id.closeBut).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        RecyclerView contentRv = dialog.findViewById(R.id.contentRv);

        //创建适配器，将数据传递给适配器
        RadioGroupAdapter mAdapter = new RadioGroupAdapter(context, list);
        //设置布局管理器
        contentRv.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
        //设置适配器adapter
        contentRv.setAdapter(mAdapter);

    }
}
